#pragma once

#include "../Datasources/WavFileSampleReader.h"
#include "../Datasources/FolderReader.h"
#include "../Classifiers/Perceptron.h"
#include "../Classifiers/ChaineApprentissage.h"
#include "../FeatureProcessing/Labelisation.h"
#include "../FeatureProcessing/ClassifierAdapter.h"
#include "../Entities/Array.h"
#include "../Utilities/TagRule.h"
#include "../Outputs/ResultConsoleWriter.h"
#include "../Outputs/ResultFileWriter.h"
#include "../Outputs/TextFormatting.h"
#include "../Outputs/HTMLSVGFormatting.h"
#include "ProgressRecognition.h"

using namespace DataSources;
using namespace Classifiers;
using namespace FeatureProcessing;
using namespace Entities;
using namespace Utilities;
using namespace Outputs;

class ChainePerceptron : public ChaineApprentissage {
protected :
	WavFileSampleReader::type_pointer wavFile;

public:
	ChainePerceptron(string _baseA, string _baseT, string _dest, Array<TagRule> & _rules ,
		ChaineApprentissagePtr _clustering):
		ChaineApprentissage(new Perceptron()){
		wavFile = new WavFileSampleReader;
		setTrainingReader(new FolderReader(wavFile, _baseA));
		setReader(new FolderReader(wavFile, _baseT));
		addProcessor(new Adapters::ClassifierAdapter(_clustering));
		addProcessor(new Labelisation(_rules));
		ResultFormattingPtr formatting = new HTMLSVGFormatting("images\\");
		addListener(new ProgressRecognition(reader->getLen()));
		setWriter(new ResultFileWriter(formatting, _dest));
	}

	void train(){
		ChaineApprentissage::train();
	}

	void recognize(){
		ChaineApprentissage::recognize();
		getWriter()->flush();
	}
};